class Solution(object):
    def canSeePersonsCount(self, heights):
        n = len(heights)
        ans = [0] * n
        st = []
        for index, num in enumerate(heights):
            while st and num >= st[-1][0]:
                _, last_index = st.pop()
                ans[last_index] += 1
            if st:
                ans[st[-1][1]] += 1
            st.append([num, index])
        return ans
data = Solution()
heights = [10,6,8,5,11,9]
print(data.canSeePersonsCount(heights))